package cn.gengms.chat;

import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

@RestController
public class MainController {

    @RequestMapping("/sureRoom/{roomId}")
    public Result sureRoom(@PathVariable("roomId") String roomId){
        return new Result(200,"获取成功",ChatSocketServer.clients.containsKey(roomId));
    }

    @PostMapping("/rsa")
    public  Result generateBase64PublicKey() {
        return new Result(200,"获取成功",RSAUtils.generateBase64PublicKey());
    }

    @PostMapping("/upload")
    public Result upload(MultipartFile file) throws IOException {
        System.out.println("图片");
        String upload = AliOSSUtil.upload(file);
        return new Result(200,"上传成功",upload);
    }

}
